class Solution:
    def replaceSpace(self, s: str) -> str:
        # 因为在 python 中, 字符串是不可变类型, 所以尽量不要每次都做字符串拼接, 先将结果存成 list, 最后一起拼接
        new = []
        for i in s:
            if i == " ": new.append("%20")
            else: new.append(i)
        
        return "".join(new)


if __name__ == '__main__':
    s = "We are happy."
    print(s)
    
    solution = Solution()
    new_s = solution.replaceSpace(s)

    print(new_s)
    print("Done!")